package com.kadron.common;

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

public class KUtil {

	public static boolean isEmpty(String label) {
		return label == null || label.trim().equals("");
	}
	
	public static Date getMoment() {
		return Calendar.getInstance(TimeZone.getTimeZone(KConst.TIME_ZONE_ID), KConst.LOCALE).getTime();
	}
	
	public static Date getYearAhead(Date moment) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(moment);
		cal.add(Calendar.YEAR, 1);
		return cal.getTime();
	}
	
	public static Date getYearAgo(Date moment) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(moment);
		cal.add(Calendar.YEAR, -1);
		return cal.getTime();
	}
	
	public static Date getMonthAgo(Date moment) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(moment);
		cal.add(Calendar.MONTH, -1);
		return cal.getTime();
	}
	
	public static Date getBirthdayDays(Date moment) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(moment);
		cal.add(Calendar.DATE, 7);
		return cal.getTime();
	}
	
	public static boolean isLeapYear(int year) {
		return (year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0));
	}
	
}
